var Slideshow = function(options) {
    this.options = options;
    this.init();
}
Slideshow.prototype = {
    params: {
        scrollPicture: {},
        navHeight: 0,
        placeholderImg: '',
        imgs: [],
        dotColor: '',
        dotActiveColor: ''
    },
    init: function() {
        this.initParams();
        this.initEvent();
    },
    initParams: function() {
        this.params.scrollPicture = api.require('UIScrollPicture');
        this.params.navHeight = this.options.navHeight || 0;
        this.params.placeholderImg = this.options.placeholderImg || '';
        this.params.imgs = this.options.imgs || [];
        this.params.dotColor = this.options.dotColor || '#E0FFFF';
        this.params.dotActiveColor = this.options.dotActiveColor || '#1abc9c';
    },
    slideShow: function() {
        var _this = this;
        console.log(_this.params.navHeight)
        document.body.style.paddingTop = api.winWidth / 2.8 + parseFloat(_this.params.navHeight) + 'px';
        console.log(document.body.style.paddingTop)
        _this.params.scrollPicture.open({
            rect: {
                x: 0,
                y: _this.params.navHeight,
                w: api.winWidth,
                h: api.winWidth / 2.8
            },
            data: {
                paths: _this.params.imgs,
                captions: []
            },
            styles: {
                caption: {
                    height: 30,
                    color: '#E0FFFF',
                    size: 15,
                    bgColor: '#696969',
                    position: 'bottom'
                },
                indicator: {
                    align: 'center',
                    color: _this.params.dotColor,
                    activeColor: _this.params.dotActiveColor
                }
            },
            placeholderImg: _this.params.placeholderImg,
            contentMode: 'scaleToFill',
            interval: 3,
            loop: true,
            fixedOn: api.frameName,
            fixed: false
        }, function(ret, err) {
            if (ret) {
                console.log(JSON.stringify(ret));
            } else {
                console.log(JSON.stringify(err));
            }
        });
    },
    initEvent: function() {
        var _this = this;
        _this.slideShow();
    }
}
